home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Src Code / TEELISB.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  20.8 KB  |  748 lines

  1. {*****************************************}
  2. {   TeeChart-Pro 4.0  TChartListBox class }
  3. {   Copyright (c) 1995-98 David Berneda   }
  4. {       Component Registration Unit       }
  5. {*****************************************}
  6. {$I teedefs.inc}
  7. unit TeeLisB;
  8.  
  9. interface
  10.  
  11. Uses WinTypes,WinProcs,Messages,StdCtrls,Chart,Classes,Graphics,Teengine,
  12.      Forms,Menus,Controls;
  13.  
  14. type TChartListBox=class;
  15.  
  16.      TDblClickSeriesEvent=procedure(Sender:TChartListBox; Index:Integer) of object;
  17.  
  18.      PListBoxSection=^TListBoxSection;
  19.      TListBoxSection=record
  20.        Width   : Integer;
  21.        Visible : Boolean;
  22.      end;
  23.  
  24.      TListBoxSections=class(TList)
  25.      private
  26.        function GetSection(Index:Integer):TListBoxSection;
  27.        Procedure SetSection(Index:Integer; Const Value:TListBoxSection);
  28.      public
  29.        Procedure AddSection(AWidth:Integer);
  30.        Function SectionLeft(Index:Integer):Integer;
  31.        property Section[Index:Integer]:TListBoxSection read GetSection
  32.                           write SetSection; {$IFNDEF D1}default;{$ENDIF}
  33.      end;
  34.  
  35.      TChartListBox=class(TCustomListBox)
  36.      private
  37.        FActiveSeries     : TCheckBox;
  38.        FAllowDelete      : Boolean;
  39.        FAskDelete        : Boolean;
  40.        FChart            : TCustomChart;
  41.        FHitTest          : TPoint;
  42.        FSections         : TListBoxSections;
  43.        FOnEditSeries     : TDblClickSeriesEvent;
  44.        FOtherItems       : TStrings;
  45.        FOtherItemsChange : TNotifyEvent;
  46.        FRefresh          : TNotifyEvent;
  47.        FSeriesBitmap     : TBitmap;
  48.        ComingFromDoubleClick:Boolean;
  49.        procedure LBSeriesClick(Sender: TObject);
  50.        procedure LBSeriesDragDrop(Sender, Source: TObject; X,Y: Integer);
  51.        procedure LBSeriesDrawItem(Control: TWinControl; Index: Integer;
  52.                                            Rect: TRect; State: TOwnerDrawState);
  53.        procedure LBSeriesDragOver( Sender, Source: TObject; X,
  54.                                    Y: Integer; State: TDragState; var Accept: Boolean);
  55.        procedure LBSeriesKeyUp(Sender: TObject; var Key: Word;
  56.                                        Shift: TShiftState);
  57.        procedure LBSeriesMouseDown( Sender: TObject;
  58.                                     Button: TMouseButton; Shift: TShiftState;
  59.                                     X, Y: Integer);
  60.        procedure DoDblClick(Sender: TObject);
  61.        procedure DoRefresh;
  62.        procedure SetChart(Value:TCustomChart);
  63.        procedure SetSectionVisible(Index:Integer; Value:Boolean);
  64.      protected
  65.        procedure Notification(AComponent: TComponent;
  66.                               Operation: TOperation); override;
  67.        procedure WMSetCursor(var Msg: TWMSetCursor); message WM_SETCURSOR;
  68.        procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
  69.      public
  70.        Constructor Create(AOwner:TComponent); override;
  71.        Destructor Destroy; override;
  72.  
  73.        property ActiveCheckBox:TCheckBox read FActiveSeries;
  74.        Function AddSeriesGallery:TChartSeries;
  75.        procedure ChangeTypeSeries(Sender: TObject);
  76.        procedure ClearItems;
  77.        Procedure CloneSeries;
  78.        Procedure DeleteSeries;
  79.        procedure FillSeries(OldSeries:TChartSeries);
  80.        Procedure MoveCurrentDown;
  81.        Procedure MoveCurrentUp;
  82.        property OtherItems:TStrings read FOtherItems write FOtherItems;
  83.        Function PointInSection(Const P:TPoint; ASection:Longint):Boolean;
  84.        Procedure RenameSeries;
  85.        Function SeriesAtMousePos(Var p:TPoint):Longint;
  86.        procedure SwapSeries(tmp1,tmp2:Longint);
  87.        Function SelectedSeries:TChartSeries;
  88.        property Sections:TListBoxSections read FSections;
  89.        Function GetShowActive:Boolean;
  90.        Procedure SetShowActive(Value:Boolean);
  91.        Function GetShowIcon:Boolean;
  92.        Procedure SetShowIcon(Value:Boolean);
  93.        Function GetShowColor:Boolean;
  94.        Procedure SetShowColor(Value:Boolean);
  95.        Function GetShowTitle:Boolean;
  96.        Procedure SetShowTitle(Value:Boolean);
  97.      published
  98.        property AllowDeleteSeries : Boolean read FAllowDelete
  99.                                   write FAllowDelete default True;
  100.        property AskDelete:Boolean read FAskDelete write FAskDelete
  101.                                   default True;
  102.        property Chart:TCustomChart read FChart write SetChart;
  103.        property OnOtherItemsChange:TNotifyEvent read FOtherItemsChange
  104.                                               write FOtherItemsChange;
  105.        property OnDblClickSeries:TDblClickSeriesEvent read FOnEditSeries
  106.                                                   write FOnEditSeries;
  107.        property OnRefresh:TNotifyEvent read FRefresh write FRefresh;
  108.        property ShowActiveCheck:Boolean read GetShowActive
  109.                                         write SetShowActive default True;
  110.        property ShowSeriesColor:Boolean read GetShowColor
  111.                                            write SetShowColor default True;
  112.        property ShowSeriesIcon:Boolean read GetShowIcon
  113.                                            write SetShowIcon default True;
  114.        property ShowSeriesTitle:Boolean read GetShowTitle
  115.                                            write SetShowTitle default True;
  116.  
  117.        property Align;
  118.        property BorderStyle;
  119.        property Color;
  120.        property Ctl3D;
  121.        property Enabled;
  122.        property ExtendedSelect;
  123.        property Font;
  124.        {$IFDEF D3}
  125.        property ImeMode;
  126.        property ImeName;
  127.        {$ENDIF}
  128.        property MultiSelect;
  129.        property ParentColor;
  130.        property ParentCtl3D;
  131.        property ParentFont;
  132.        property ParentShowHint;
  133.        property PopupMenu;
  134.        property ShowHint;
  135.        property TabOrder;
  136.        property TabStop;
  137.        property Visible;
  138.        property OnEnter;
  139.        property OnExit;
  140.        property OnKeyDown;
  141.        property OnKeyPress;
  142.      end;
  143.  
  144. procedure MoveList(Source,Dest:TListBox);
  145. procedure MoveListAll(Source,Dest:TListBox);
  146.  
  147. implementation
  148.  
  149. {$IFDEF D1}
  150. {$R TEEBMPS.R16}
  151. {$ELSE}
  152. {$R TEEBMPS.RES}
  153. {$ENDIF}
  154.  
  155. Uses PenDlg,TeeGally, Dialogs, TeeConst, SysUtils,TeeProcs;
  156.  
  157. { TListBoxSections }
  158. Function TListBoxSections.SectionLeft(Index:Integer):Integer;
  159. var t:Integer;
  160. begin
  161.   result:=0;
  162.   for t:=1 to Index do
  163.   With Section[t-1] do
  164.   if Visible then Inc(result,Width);
  165. end;
  166.  
  167. Procedure TListBoxSections.AddSection(AWidth:Integer);
  168. Var P:^TListBoxSection;
  169. begin
  170.   New(P);
  171.   P^.Visible:=True;
  172.   P^.Width:=AWidth;
  173.   Add(P);
  174. end;
  175.  
  176. function TListBoxSections.GetSection(Index:Integer):TListBoxSection;
  177. begin
  178.   result:=TListBoxSection(inherited Items[Index]^);
  179. end;
  180.  
  181. Procedure TListBoxSections.SetSection(Index:Integer; Const Value:TListBoxSection);
  182. begin
  183.   While Count<Index do Add(nil);
  184.   TListBoxSection(inherited Items[Index]^):=Value;
  185. end;
  186.  
  187.  
  188. { TChartListBox }
  189. Constructor TChartListBox.Create(AOwner:TComponent);
  190. begin
  191.   inherited Create(AOwner);
  192.   ComingFromDoubleClick:=False;
  193.  
  194.   FSeriesBitmap:=TBitmap.Create;
  195.   FActiveSeries:=TCheckBox.Create(nil);
  196.   With FActiveSeries do
  197.   begin
  198.     ParentColor := True;
  199.     Caption:='';
  200.     Height:=12;
  201.     Width:=Height;
  202.     Visible:=False;
  203.   end;
  204.   FSections:=TListBoxSections.Create;
  205.   FSections.AddSection(26);
  206.   FSections.AddSection(16);
  207.   FSections.AddSection(26);
  208.   FSections.AddSection(216);
  209.  
  210.   OnDragDrop:=LBSeriesDragDrop;
  211.   OnDrawItem:=LBSeriesDrawItem;
  212.   OnDragOver:=LBSeriesDragOver;
  213.   OnMouseDown:=LBSeriesMouseDown;
  214.   OnClick:=LBSeriesClick;
  215.   OnDblClick:=DoDblClick;
  216.   OnKeyUp:=LBSeriesKeyUp;
  217.   Style:=lbOwnerDrawFixed;
  218.   ItemHeight:=27;
  219.   Sorted:=False;
  220.   MultiSelect:=True;
  221.   FAskDelete:=True;
  222.   FAllowDelete:=True;
  223. end;
  224.  
  225. Destructor TChartListBox.Destroy;
  226. var t:Integer;
  227. begin
  228.   {$IFNDEF D1}
  229.   FActiveSeries.Free;
  230.   {$ENDIF}
  231.   FSeriesBitmap.Free;
  232.   for t:=0 to FSections.Count-1 do
  233.       Dispose(PListBoxSection(FSections.Items[t]));
  234.   FSections.Free;
  235.   inherited Destroy;
  236. end;
  237.  
  238. procedure TChartListBox.LBSeriesDragDrop(Sender, Source: TObject; X,
  239.   Y: Integer);
  240. var tmp1 : Longint;
  241.     tmp2 : Longint;
  242. begin
  243.   With TCustomListBox(Sender) do
  244.   if ItemIndex<>-1 then
  245.   begin
  246.     tmp1:=ItemIndex;
  247.     tmp2:=ItemAtPos(Point(X,Y),True);
  248.     if (tmp2<>-1) and (tmp1<>tmp2) then SwapSeries(tmp1,tmp2);
  249.   end;
  250. end;
  251.  
  252. procedure TChartListBox.DoRefresh;
  253. begin
  254.   if Assigned(FRefresh) then FRefresh(Self);
  255. end;
  256.  
  257. procedure TChartListBox.SetChart(Value:TCustomChart);
  258. begin
  259.   FChart:=Value;
  260.   if Assigned(FChart) then
  261.   begin
  262.     {$IFNDEF D1}
  263.     FChart.FreeNotification(Self);
  264.     {$ENDIF}
  265.     FillSeries(nil);
  266.   end
  267.   else ClearItems;
  268. end;
  269.  
  270. procedure TChartListBox.ClearItems;
  271. begin
  272.   if not (csDestroying in ComponentState) then
  273.   begin
  274.     Items.Clear;
  275.     if Assigned(FOtherItems) then FOtherItems.Clear;
  276.   end;
  277. end;
  278.  
  279. procedure TChartListBox.SwapSeries(tmp1,tmp2:Longint);
  280. begin
  281.   if Assigned(FChart) then
  282.   begin
  283.     Items.Exchange(tmp1,tmp2);
  284.     if Assigned(FOtherItems) then FOtherItems.Exchange(tmp1,tmp2);
  285.     FChart.ExchangeSeries(tmp1,tmp2);
  286.     GetParentForm(Self).ActiveControl:=Self;
  287.     Selected[tmp2]:=True;
  288.     Repaint;
  289.     DoRefresh;
  290.   end;
  291. end;
  292.  
  293. procedure TChartListBox.LBSeriesClick(Sender: TObject);
  294. begin
  295.   DoRefresh;
  296. end;
  297.  
  298. procedure TChartListBox.LBSeriesDrawItem(Control: TWinControl;
  299.   Index: Integer; Rect: TRect; State: TOwnerDrawState);
  300. Const BrushColors : Array[Boolean] of TColor=(clWindow,clHighLight);
  301.       FontColors  : Array[Boolean] of TColor=(clWindowText,clHighlightText);
  302. var tmp       : Integer;
  303.     tmpSeries : TChartSeries;
  304.     tmpR      : TRect;
  305.     CBRect    : TRect;
  306.     tmpCanvas : TCanvas;
  307.     OldCanvas : TCanvas;
  308. begin
  309.   if FActiveSeries.Parent=nil then
  310.   begin
  311.     FActiveSeries.Left   :=Left;
  312.     FActiveSeries.Top    :=Top;
  313.     FActiveSeries.Parent :=Parent;
  314.     FActiveSeries.Visible:=True;
  315.     FActiveSeries.SendToBack;
  316.   end;
  317.  
  318.   tmpCanvas:=Canvas;
  319.   With tmpCanvas do
  320.   begin
  321.     if odSelected in State then Brush.Color:=clHighLight
  322.                            else Brush.Color:=Self.Color;
  323.     FillRect(Rect);
  324.  
  325.     Brush.Color:=Self.Color;
  326.     Brush.Style:=bsSolid;
  327.     tmpR.Top    :=Rect.Top;
  328.     tmpR.Bottom :=Rect.Bottom;
  329.     tmpR.Left   :=Rect.Left;
  330.     tmpR.Right  :=Sections.SectionLeft(3)-4;
  331.     FillRect(tmpR);
  332.  
  333.     tmpSeries:=FChart[Index];
  334.  
  335.     if ShowSeriesIcon then
  336.     begin
  337.       tmpSeries.GetBitmapEditor(FSeriesBitmap);
  338.       {$IFDEF D3}
  339.       FSeriesBitmap.Transparent:=True;
  340.       {$ENDIF}
  341.       Draw(Sections.SectionLeft(0),Rect.Top+2,FSeriesBitmap);
  342.     end;
  343.  
  344.     if ShowSeriesColor and (not tmpSeries.ColorEachPoint) then
  345.     begin
  346.       tmp:=Sections.SectionLeft(2)-2;
  347.       tmpR:=Classes.Rect(tmp,Rect.Top,tmp+Sections.Section[2].Width,Rect.Bottom);
  348.       InflateRect(tmpR,-4,-4);
  349.  
  350.       Brush.Style:=bsSolid;
  351.       Brush.Color:=FChart.Legend.Color;
  352.       With FChart do
  353.       begin
  354.         OldCanvas:=Canvas.ReferenceCanvas;
  355.         Canvas.ReferenceCanvas:=tmpCanvas;
  356.         try
  357.           Series[Index].DrawLegend(-1,tmpR);
  358.         finally
  359.           Canvas.ReferenceCanvas:=OldCanvas;
  360.         end;
  361.       end;
  362.     end;
  363.  
  364.     if ShowActiveCheck then
  365.     begin
  366.       tmp:=Sections.SectionLeft(1);
  367.       CBRect:=Classes.Rect(tmp,Rect.Top+6,tmp+12,Rect.Top+18);
  368.  
  369.       {$IFDEF D1}
  370.       Brush.Style:=bsClear;
  371.       SetBkMode(Handle,Transparent);
  372.       Pen.Color:=clBlack;
  373.       Pen.Style:=psSolid;
  374.       With CBRect do Rectangle(Left,Top,Right,Bottom);
  375.       if tmpSeries.Active then
  376.       With CBRect do
  377.       begin
  378.         MoveTo(Left,Top);
  379.         LineTo(Right,Bottom);
  380.         MoveTo(Left,Bottom-1);
  381.         LineTo(Right,Top-1);
  382.       end;
  383.       {$ELSE}
  384.       With FActiveSeries do
  385.       begin
  386.         Checked:=tmpSeries.Active;
  387.         PaintTo(tmpCanvas.Handle,CBRect.Left,CBRect.Top);
  388.       end;
  389.       {$ENDIF}
  390.     end;
  391.  
  392.     if ShowSeriesTitle then
  393.     begin
  394.       if odSelected in State then Font.Color:=clHighlightText
  395.                              else Font.Color:=Self.Font.Color;
  396.       Brush.Style:=bsClear;
  397.       TextOut(Sections.SectionLeft(3),Rect.Top+((ItemHeight-TextHeight('W')) div 2),Items[Index]);
  398.     end;
  399.   end;
  400. end;
  401.  
  402. Function TChartListBox.SelectedSeries:TChartSeries;
  403. begin
  404.   if (ItemIndex<>-1) and (ItemIndex<FChart.SeriesCount) then
  405.      result:=TChartSeries(Items.Objects[ItemIndex])
  406.   else
  407.      result:=nil;
  408. end;
  409.  
  410. procedure TChartListBox.LBSeriesDragOver(Sender, Source: TObject; X,
  411.   Y: Integer; State: TDragState; var Accept: Boolean);
  412. begin
  413.   Accept:=Sender=Source;
  414. end;
  415.  
  416. Function TChartListBox.SeriesAtMousePos(Var p:TPoint):Longint;
  417. begin
  418.   GetCursorPos(p);
  419.   p:=ScreenToClient(p);
  420.   result:=ItemAtPos(p,True);
  421. end;
  422.  
  423. Function TChartListBox.PointInSection(Const P:TPoint; ASection:Longint):Boolean;
  424. Var tmpPos : Longint;
  425. begin
  426.   if Sections.Section[ASection].Visible then
  427.   begin
  428.     tmpPos:=Sections.SectionLeft(ASection);
  429.     result:=(p.x>tmpPos) and (p.x<tmpPos+Sections.Section[ASection].Width);
  430.   end
  431.   else result:=False;
  432. end;
  433.  
  434. procedure TChartListBox.FillSeries(OldSeries:TChartSeries);
  435. var t                : Longint;
  436.     tmpSelectedIndex : Longint;
  437.     tmpSeries        : TChartSeries;
  438.     tmpSt            : String;
  439. Begin
  440.   ClearItems;
  441.   if Assigned(FChart) then
  442.   With FChart do
  443.   Begin
  444.     tmpSelectedIndex:=-1;
  445.     for t:=0 to SeriesCount-1 do
  446.     begin
  447.       tmpSeries:=Series[t];
  448.       if tmpSeries.Title<>'' then tmpSt:=tmpSeries.Title
  449.                              else tmpSt:=tmpSeries.Name;
  450.       Items.AddObject(tmpSt,tmpSeries);
  451.       if Assigned(FOtherItems) then
  452.          FOtherItems.AddObject(tmpSt,tmpSeries);
  453.       if Assigned(OldSeries) and (tmpSeries=OldSeries) then
  454.          tmpSelectedIndex:=t;
  455.     end;
  456.     if tmpSelectedIndex=-1 then
  457.        if SeriesCount>0 then tmpSelectedIndex:=0;
  458.     if tmpSelectedIndex<>-1 then
  459.        Selected[tmpSelectedIndex]:=True
  460.     else
  461.     if Assigned(FOtherItemsChange) then FOtherItemsChange(Self);
  462.     DoRefresh;
  463.   end;
  464. end;
  465.  
  466. procedure TChartListBox.ChangeTypeSeries(Sender: TObject);
  467. var tmpSeries : TChartSeries;
  468.     NewClass  : TChartSeriesClass;
  469.     t         : Longint;
  470.     FirstTime : Boolean;
  471. begin
  472.   if SelCount>0 then
  473.   begin
  474.     FirstTime:=True;
  475.     NewClass:=nil;
  476.     for t:=0 to Items.Count-1 do
  477.     if Selected[t] then
  478.     begin
  479.       tmpSeries:=FChart[t];
  480.       if FirstTime then
  481.       begin
  482.         ChangeSeriesTypeGallery(tmpSeries.Owner,tmpSeries);
  483.         NewClass:=TChartSeriesClass(tmpSeries.ClassType);
  484.         FirstTime:=False;
  485.       end
  486.       else ChangeSeriesType(tmpSeries,NewClass);
  487.     end;
  488.     FillSeries(tmpSeries);
  489.   end;
  490. end;
  491.  
  492. procedure TChartListBox.DoDblClick(Sender: TObject);
  493. var p   : TPoint;
  494.     tmp : Longint;
  495. begin
  496.   ComingFromDoubleClick:=True;
  497.   tmp:=SeriesAtMousePos(p);
  498.   if (tmp<>-1) and Selected[tmp] then
  499.   begin
  500.     if PointInSection(p,0) then ChangeTypeSeries(Self)
  501.     else
  502.     if PointInSection(p,2) then
  503.     begin
  504.       With FChart[tmp] do
  505.       if not ColorEachPoint then
  506.       begin
  507.         SeriesColor:=EditColor(Self,SeriesColor);
  508.         Self.Repaint;
  509.       end;
  510.     end
  511.     else
  512.     if PointInSection(p,3) then
  513.        if Assigned(FOnEditSeries) then FOnEditSeries(Self,tmp);
  514.   end;
  515. end;
  516.  
  517. procedure TChartListBox.LBSeriesMouseDown(Sender: TObject;
  518.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  519. var tmp : Longint;
  520.     p   : TPoint;
  521. begin
  522.   if (ItemIndex<>-1) then
  523.   begin
  524.     tmp:=SeriesAtMousePos(p);
  525.     if (tmp<>-1) and (PointInSection(p,1)) then
  526.     begin
  527.       with FChart[tmp] do Active:=not Active;
  528.       Repaint;
  529.     end
  530.     else
  531.     if PointInSection(p,3) and (not ComingFromDoubleClick) and
  532.        (not (ssShift in Shift)) and
  533.        (not (ssCtrl in Shift)) and
  534.        ( ( ssLeft in Shift) ) then
  535.             BeginDrag(False);
  536.     ComingFromDoubleClick:=False;
  537.     if Assigned(FOtherItemsChange) then FOtherItemsChange(Self);
  538.   end;
  539. end;
  540.  
  541. Procedure TChartListBox.MoveCurrentUp;
  542. begin
  543.   if ItemIndex>0 then SwapSeries(ItemIndex,ItemIndex-1);
  544. end;
  545.  
  546. Procedure TChartListBox.MoveCurrentDown;
  547. begin
  548.   if (ItemIndex<>-1) and (ItemIndex<Items.Count-1) then
  549.      SwapSeries(ItemIndex,ItemIndex+1);
  550. end;
  551.  
  552. Procedure TChartListBox.DeleteSeries;
  553. var GoDelete       : Boolean;
  554.     NewFocusSeries : TChartSeries;
  555.     t              : Longint;
  556.     i              : Longint;
  557.     tmpSt          : String;
  558. begin
  559.   if SelCount>0 then
  560.   begin
  561.     if FAskDelete then
  562.     begin
  563.       if SelCount=1 then tmpSt:=SelectedSeries.Name
  564.                     else tmpSt:=TeeMsg_SelectedSeries;
  565.       GoDelete:=MessageDlg( Format(TeeMsg_SureToDeleteSeries,[tmpSt]),
  566.                      mtConfirmation,[mbYes,mbNo],0)=mrYes;
  567.     end
  568.     else GoDelete:=True;
  569.     if GoDelete then
  570.     begin
  571.       NewFocusSeries:=nil;
  572.       t:=0;
  573.       for i:=0 to Items.Count-1 do
  574.       begin
  575.         if Selected[i] then
  576.         begin
  577.          FChart[t].Free;
  578.          if t>(FChart.SeriesCount-1) then t:=FChart.SeriesCount-1;
  579.          if (t>=0) and (t<FChart.SeriesCount) then
  580.             NewFocusSeries:=FChart[t]
  581.          else
  582.             NewFocusSeries:=nil;
  583.         end
  584.         else Inc(t);
  585.       end;
  586.       FillSeries(NewFocusSeries);
  587.     end;
  588.   end;
  589. end;
  590.  
  591. Procedure TChartListBox.CloneSeries;
  592. begin
  593.   if ItemIndex<>-1 then FillSeries(CloneChartSeries(SelectedSeries));
  594. end;
  595.  
  596. procedure TChartListBox.LBSeriesKeyUp(Sender: TObject; var Key: Word;
  597.   Shift: TShiftState);
  598. begin
  599.   if (Key=VK_DELETE) and (FAllowDelete) then DeleteSeries;
  600. end;
  601.  
  602. Procedure TChartListBox.RenameSeries;
  603. var tmp       : Longint;
  604.     tmpSeries : TChartSeries;
  605.     tmpSt     : String;
  606. begin
  607.   tmp:=ItemIndex;
  608.   if tmp<>-1 then
  609.   begin
  610.     tmpSeries:=SelectedSeries;
  611.     tmpSt:=tmpSeries.Title;
  612.     if tmpSt='' then tmpSt:=tmpSeries.Name;
  613.     if InputQuery( TeeMsg_ChangeSeriesTitle,
  614.                    TeeMsg_NewSeriesTitle,tmpSt) then
  615.     if tmpSt<>'' then
  616.     begin
  617.       if tmpSt<>tmpSeries.Name then tmpSeries.Title:=tmpSt;
  618.       Items[tmp]:=tmpSt;
  619.       if Assigned(FOtherItems) then FOtherItems[tmp]:=tmpSt;
  620.     end;
  621.     Selected[tmp]:=True;
  622.   end;
  623. end;
  624.  
  625. Function TChartListBox.AddSeriesGallery:TChartSeries;
  626. begin
  627.   result:=nil;
  628.   if Assigned(FChart) then
  629.      result:=CreateNewSeriesGallery(FChart.Owner,SelectedSeries,FChart,True,True);
  630.   if Assigned(result) then FillSeries(result);
  631. end;
  632.  
  633. procedure TChartListBox.Notification(AComponent: TComponent;
  634.   Operation: TOperation);
  635. begin
  636.   inherited Notification(AComponent, Operation);
  637.   {$IFDEF D1}
  638.   if not (csDestroying in ComponentState) then
  639.   {$ENDIF}
  640.   if Operation=opRemove then
  641.      if Assigned(FChart) and (AComponent=FChart) then
  642.         Chart:=nil;
  643. end;
  644.  
  645. procedure TChartListBox.WMNCHitTest(var Msg: TWMNCHitTest);
  646. begin
  647.   inherited;
  648.   FHitTest := SmallPointToPoint(Msg.Pos);
  649. end;
  650.  
  651. procedure TChartListBox.WMSetCursor(var Msg: TWMSetCursor);
  652. var I: Integer;
  653. begin
  654.   if csDesigning in ComponentState then Exit;
  655.   FHitTest := ScreenToClient(FHitTest);
  656.   with Msg do
  657.   if HitTest = HTCLIENT then
  658.       for I := 0 to FSections.Count - 2 do  { don't count last section }
  659.       begin
  660.         if PointInSection(FHitTest,I) then
  661.         begin
  662.           if (I=0) or (I=2) then
  663.           begin
  664.             SetCursor(Screen.Cursors[crTeeHand]);
  665.             exit;
  666.           end
  667.           else break;
  668.         end;
  669.       end;
  670.   inherited;
  671. end;
  672.  
  673. Function TChartListBox.GetShowActive:Boolean;
  674. begin
  675.   result:=Sections.Section[1].Visible;
  676. end;
  677.  
  678. procedure TChartListBox.SetSectionVisible(Index:Integer; Value:Boolean);
  679. var tmp:TListBoxSection;
  680. begin
  681.   tmp:=Sections.Section[Index];
  682.   tmp.Visible:=Value;
  683.   Sections.Section[Index]:=tmp;
  684.   Repaint;
  685. end;
  686.  
  687. procedure TChartListBox.SetShowActive(Value:Boolean);
  688. begin
  689.   SetSectionVisible(1,Value);
  690. end;
  691.  
  692. Function TChartListBox.GetShowIcon:Boolean;
  693. begin
  694.   result:=Sections.Section[0].Visible;
  695. end;
  696.  
  697. procedure TChartListBox.SetShowIcon(Value:Boolean);
  698. begin
  699.   SetSectionVisible(0,Value);
  700. end;
  701.  
  702. Function TChartListBox.GetShowColor:Boolean;
  703. begin
  704.   result:=Sections.Section[2].Visible;
  705. end;
  706.  
  707. procedure TChartListBox.SetShowColor(Value:Boolean);
  708. begin
  709.   SetSectionVisible(2,Value);
  710. end;
  711.  
  712. Function TChartListBox.GetShowTitle:Boolean;
  713. begin
  714.   result:=Sections.Section[3].Visible;
  715. end;
  716.  
  717. procedure TChartListBox.SetShowTitle(Value:Boolean);
  718. begin
  719.   SetSectionVisible(3,Value);
  720. end;
  721.  
  722. { Helper Listbox methods... }
  723. procedure MoveList(Source,Dest:TListBox);
  724. var t:Integer;
  725. begin
  726.   with Source do
  727.   begin
  728.     for t:=0 to Items.Count-1 do
  729.         if Selected[t] then Dest.Items.AddObject(Items[t],Items.Objects[t]);
  730.     t:=0;
  731.     While t<Items.Count do
  732.     begin
  733.       if Selected[t] then Items.Delete(t)
  734.                      else Inc(t);
  735.     end;
  736.   end;
  737. end;
  738.  
  739. procedure MoveListAll(Source,Dest:TListBox);
  740. var t:Integer;
  741. begin
  742.   With Source do
  743.   for t:=0 to Items.Count-1 do Dest.Items.AddObject(Items[t],Items.Objects[t]);
  744.   Source.Clear;
  745. end;
  746.  
  747. end.
  748.